package day18;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * 将一个文件复制到D盘下面
 * 
 * @author wangbiao
 * 
 */
public class CopyTextTest {

	public static void main(String[] args) {
		FileReader fr = null;
		FileWriter fw = null;
		try {
			fr = new FileReader(
					"D:\\MyProject\\javatest\\src\\day18\\DateFormatDemo.java");
			fw = new FileWriter("D:\\demo.java");
			char[] chs = new char[1024];
			int len = 0;
			while ((len = fr.read(chs)) != -1) {
				fw.write(chs, 0, len);
				fw.flush();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (null != fr) {
				try {
					fr.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			
			if (null != fw) {
				try {
					fw.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
